package com.tmall.tmall.mapper;

import com.tmall.tmall.pojo.User;
import com.tmall.tmall.pojo.UserLogin;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface UserMapper {


    @Select("select * from user where name=#{name} and password=#{password} and delete_at is null")
    public User login(UserLogin user);
    @Select("select * from user where name=#{name} and delete_at is null")
    User getByName(UserLogin userLogin);

    @Insert("insert into user(name,password,type) value (#{name},#{password},#{type})")
    void insert(UserLogin userLogin);

//    @Select("select * from user where delete_at is null")
    List<User> page(String name);

    @Select("select * from user where delete_at is null and id=#{id}")
    User getById(Integer id);

    void update(User user);

    @Select("select * from user where id=#{id} and password=#{password} and delete_at is null")
    User checkPassword(@Param("id") Integer id, @Param("password") String password);

    @Update("update user set password=#{password} where id=#{id}")
    void updatePassword(@Param("id") Integer id, @Param("password") String password);
}
